#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int > vec;
typedef pair < int , int > pii;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 4e7 + 10;
const int mod = 998244353;

int pri[N], pnum;
bool v[N];

void init(int l) {
	rep(i, 2, l) {
		if(!v[i]) pri[++pnum] = i;
		rep(j, 1, pnum) {
			if(pri[j] * i > l) break;
			v[pri[j] * i] = true;
			if(i % pri[j] == 0) break;
		}
	} cerr << pnum << endl;
}

ll tcalc(ll x) {
	ll cur = 1, tot = 0;
	rep(i, 0, 114514) {
		ll t = cur; if(t > x) break;
		rep(j, 0, 1919810) {
			if(t > x) break;
			tot += i + j; tot %= mod;
			t *= 5;
		}
		cur *= 2;
	} return tot;
}

ll calc(ll x) {
	ll res = 0;
	rep(i, 1, pnum) {
		ll v = x; if(pri[i] > x) break;
		if(x < 20) cerr << pri[i] << " " << res << " ";
		while(v) res += v / pri[i], v /= pri[i], res %= mod;
		if(x < 20) cerr << res << endl;
	}
	return ((res - tcalc(x)) % mod + mod) % mod;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
	rep(i, 1, 25) printf("%.25Lf\n",(long double) 1. / (i * i));
	init(34000000); int T = in;
//	cerr << "!" << tcalc(10) << endl;
	while(T--) {
		ll l, r; cin >> l >> r;
		cout << calc(r) - calc(l - 1) << endl;
	}
}
